home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PROGEDIT / 1023.ZIP / GLWP.PAS < prev    next >
Pascal/Delphi Source File  |  1986-03-14  |  55KB  |  2,135 lines

  1. {$I-,V-,C-,U-,K-,D-}
  2. Program Words;
  3.  
  4. CONST
  5.   OFF        = false;
  6.   ON         = True;
  7.   ENDLINE    = 4021;
  8.   TOPEND     = 4000;
  9.   cnotice    = '  Copyright  1986,  K. D. Sherrets,  P. O. Box 37093,  Omaha,  NE   68137';
  10. type
  11.   str255 = string[255];
  12.   Str80 = String[80];
  13.   CharSet = Set of Char;
  14.   registers = Record case integer of
  15.                  0 : (ax,bx,cx,dx,bp,si,di,ds,es,flags: integer);
  16.                  1 : (al,ah,bl,bh,cl,ch,dl,dh : byte);
  17.               End;
  18.  
  19.   Screentype  = array [1..4000] of byte;
  20.   WPLine = String[79];
  21. var
  22.   Astring    : string[80];
  23.   Att,
  24.   fcol,
  25.   frow       : byte;
  26.   Aendline   : integer;
  27.   Atopend    : integer;
  28.   heaptop    : ^integer;
  29.   Cdir,
  30.   WPFileVar,
  31.   DFilevar,
  32.   tempfile   : String[60];
  33.   WPFileName : text[$F00];
  34.   DFileName  : text[$F00];
  35.   WrapOn,
  36.   MarkBlock,
  37.   SAVED      : BOOLEAN;
  38.   sline      : array [1..endline] of ^wpline;
  39.   dline      : array [1..99] of string[79];
  40.   nomem,
  41.   noprint,
  42.   formright,
  43.   Inserton   : Boolean;
  44.   lns,
  45.   PriorLN,
  46.   MarkOne,
  47.   MarkTwo,
  48.   xx,
  49.   MAXLN,
  50.   LNN        : Integer;
  51.   newline,
  52.   ckln       : string[80];
  53.   Fword,
  54.   Junk,
  55.   Temp,
  56.   Tbuff      : string[79];
  57.   pageYN,
  58.   pause,
  59.   priorch,
  60.   NumYn,
  61.   Ch,
  62.   zip,
  63.   YN         : Char;
  64.   Last,
  65.   LineNum,
  66.   priorP,
  67.   PP,
  68.   Header,
  69.   Bottom,
  70.   margin,
  71.   pagesize,
  72.   count,
  73.   linewidth,
  74.   TopLine,
  75.   online,
  76.   OldXpos,
  77.   OldYpos,
  78.   Crtmode     : integer;
  79.   Screen      : Screentype;
  80.   Monobuffer  : Screentype absolute $B000:$0000;
  81.   Colorbuffer : Screentype absolute $B800:$0000;
  82.  
  83.  
  84. PROCEDURE Typeadapter;
  85. var
  86.   regs  : registers;
  87. BEGIN
  88.    with regs do
  89.    begin
  90.      ah := 15;
  91.      intr($10,regs);
  92.      crtmode := al;
  93.    end;
  94. END;
  95.  
  96. PROCEDURE bigw;
  97. begin
  98.   window(1,1,80,25);
  99. end;
  100.  
  101. PROCEDURE littlew;
  102. begin
  103.   window(1,1,80,22);
  104. end;
  105.  
  106.  
  107. PROCEDURE BEEP;
  108. begin
  109.    Write(chr(7));
  110. end;
  111.  
  112. PROCEDURE PromptAt(x : byte; y : byte; promptstr : str80);
  113. begin
  114.   gotoxy(x,y);
  115.   write(promptstr);clreol;
  116. end;
  117.  
  118. PROCEDURE cursor(switchon : boolean);
  119. var
  120.    regs  : registers;
  121. begin
  122.   with regs do
  123.   begin
  124.     if crtmode <> 7 then
  125.     begin
  126.       if switchon then ch := 6 else ch := $20;
  127.       cl := 7;
  128.     end
  129.     else
  130.     begin
  131.       if switchon then ch := 12 else ch := $20;
  132.       cl := 13;
  133.     end;
  134.     ah := 1;
  135.     intr($10,regs);
  136.   end;
  137. end;
  138.  
  139. PROCEDURE TextInfo;
  140. var
  141.    pageno : integer;
  142. begin
  143.    bigw;
  144.    lowvideo;
  145.    cursor(off);
  146.    if maxln >= aendline -6 then
  147.    begin
  148.      PromptAt(1,24,'Warning - Text Buffer full!  Save your file');
  149.      write(chr(7));
  150.    end;
  151.    gotoxy(20,25);
  152.    pageno := (lnn div (1+ pagesize -header-bottom)) + 1;
  153.    write('Page: ',pageno,', Line: ',LNN,', Col: ',pp+1,', Lines Used: ',maxln);clreol;
  154.    cursor(on);
  155.    highvideo;
  156. end;
  157.  
  158. PROCEDURE wpstatus;
  159. begin
  160.   bigw;
  161.   PromptAt(1,24,'"F10" = Quit,  "Alt & F10" = Help');
  162.   gotoxy(36,24);
  163.   lowvideo;
  164.   if InsertOn then write('Insert-On: ',WPFileVar)
  165.   else write('Overwrite: ',WPFileVar);
  166.   textinfo;
  167. end;
  168.  
  169. PROCEDURE writewrapon;
  170. begin
  171.   bigw;
  172.   lowvideo;
  173.   gotoxy(1,25);clreol;
  174.   if WrapOn then write('Word Wrap-ON  ') else write('Word Wrap-OFF ');
  175.   highvideo;
  176. end;
  177.  
  178.  
  179. PROCEDURE Directwrite(col,row, attrib : byte; var str : str80);
  180. begin
  181. inline($1E/
  182.        $1E/
  183.        $8A/$86/ROW/
  184.        $B3/$50/
  185.        $F6/$E3/
  186.        $2B/$DB/
  187.        $8A/$9E/COL/
  188.        $03/$C3/
  189.        $03/$C0/
  190.        $8B/$F8/
  191.        $8A/$BE/ATTrib/
  192.        $C4/$B6/Str/
  193.        $2b/$c9/
  194.        $26/$8A/$0C/
  195.        $2B/$C0/
  196.        $8E/$D8/
  197.        $A0/$49/$04/
  198.        $1F/
  199.        $2C/$07/
  200.        $74/$21/
  201.        $BA/$00/$B8/
  202.        $8E/$DA/
  203.        $BA/$DA/$03/
  204.        $46/
  205.        $26/$8A/$1C/
  206.        $EC/
  207.        $A8/$01/
  208.        $75/$FB/
  209.        $FA/
  210.        $EC/
  211.        $A8/$01/
  212.        $74/$FB/
  213.        $89/$1D/
  214.        $47/
  215.        $47/
  216.        $E2/$EB/
  217.        $2A/$C0/
  218.        $74/$0F/
  219.        $BA/$00/$B0/
  220.        $8E/$DA/
  221.        $46/
  222.        $26/$8A/$1C/
  223.        $89/$1D/
  224.        $47/
  225.        $47/
  226.        $E2/$F6/
  227.        $1F/
  228.        $FB);
  229. end;
  230.  
  231. PROCEDURE makenewline( x : integer);
  232. begin
  233.   if (sline[x] = nil) then
  234.   begin
  235.     if ((memavail * 16.0) -20000.0 < 1680) then
  236.     begin
  237.        gotoxy(1,1);
  238.        write(^G,'You are running out of memory!'); delay(600);
  239.     end;
  240.     if ((memavail * 16.0) -20000.0 > 160) then
  241.     begin
  242.       new(sline[x]);
  243.       sline[x]^ := '';
  244.     end
  245.     else begin write(^G,'Out Of Memory'); nomem := true; end;
  246.   end;
  247. end;
  248.  
  249. PROCEDURE VideoSignal(Switch : boolean);
  250. var
  251.    CrtAdapter : integer absolute $0040:$0063;
  252.    VideoMode  : byte    absolute $0040:$0065;
  253. Begin
  254.   If (Switch = Off)
  255.   then
  256.   Port[CrtAdapter+4] := (VideoMode - $08)
  257.   else
  258.   Port[CrtAdapter+4] := (VideoMode or $08);
  259. end;
  260.  
  261. procedure insertline(s : str80; lnn : integer);
  262. var y,tcount,nln :integer;
  263. begin
  264.   y := wherey;
  265.   insline;
  266.   gotoxy(1,22);
  267.   if y < 21 then clreol;
  268.   bigw;
  269.   littlew;
  270.   gotoxy(1,y);
  271.   tcount := 1;
  272.   temp:= s;
  273.   for NLN := LNN to MAXLN + 1 do
  274.   begin
  275.     makenewline(lnn + tcount);
  276.     Tbuff := sline[LNN + tcount]^;
  277.     sline[LNN + tcount]^ := temp;
  278.     temp := Tbuff;
  279.     tcount := tcount + 1;
  280.   end;
  281.   maxln :=maxln + 1;
  282. end;
  283.  
  284. function rmblks(s : str80) : str80;
  285. var  ct : integer;
  286. begin
  287.   if (length(s) > 1) and (pos(' ',s) <> 0) then
  288.   begin
  289.      ct :=0;
  290.      s := s + ' ';
  291.      while (length(s) > 0) and (s[1] = ' ') do delete(s,1,1);
  292.      repeat
  293.        ct := ct + 1;
  294.        if (s[ct] = ' ') and (s[ct+1] = ' ') then delete(s,ct,1);
  295.        if (ct = length(s)-1) and (pos('  ',s) <> 0) then ct := 0;
  296.      until ct >= length(s)-1;
  297.      while s[length(s)] = ' ' do delete(s,length(s),1);
  298.   end;
  299.   rmblks := s;
  300. end;
  301.  
  302. procedure formpara(var curline :integer);
  303. var
  304.   useddlines,lastline,oln,nln,lw,y,nlcnt : integer;
  305.   word : string[79];
  306.   right,newpara : boolean;
  307.   bufline : string[255];
  308.  
  309. procedure initialize;
  310. var x:integer;
  311. begin
  312.   for x := 1 to 99 do dline[x] := '';
  313.   right := false;
  314.   newline := '';
  315.   bufline := '';
  316.   nlcnt := 0;
  317. end;
  318.  
  319. PROCEDURE deletelines(curLn : integer; NumLn : integer);
  320. var dnln : integer; termline : string[79];
  321. begin
  322.   for dnln := maxln to maxln + numln do makenewline(dnln);
  323.   for dnln := curln-1 to maxln do sline[dnln]^ := sline[dnln+numln]^;
  324.   for dnln := maxln to maxln + numln do sline[dnln]^ := '';
  325.   maxln := maxln - numln;
  326. end;
  327.  
  328. procedure spread(var newline : str80);
  329. var i : integer;
  330.    wch : char;
  331. begin
  332.   if pos(^M,newline) <> 0 then newpara := true else newpara := false;
  333.   if ((length(newline) < lw) and (Not newpara)) and (pos(' ',newline) <> 0) then
  334.   begin
  335.       i := 0;
  336.       if right then
  337.       begin
  338.         repeat
  339.           i := i + 1;
  340.           wch := newline[i];
  341.           if wch = ' ' then
  342.           begin
  343.             insert(' ',newline,i+1);
  344.             i := i + 1;
  345.           end;
  346.           if (i >= length(newline)) and (Length(newline) < lw) then i := 1;
  347.         until (length(newline) >= lw);
  348.       end
  349.       else
  350.       begin
  351.         i := Length(newline);
  352.         if i > 0 then
  353.         while (length(newline) < lw) do
  354.         begin
  355.           i := i - 1;
  356.           wch := newline[i];
  357.           if wch = ' ' then
  358.           begin
  359.             insert(' ',newline,i + 1);
  360.             i := i - 1;
  361.           end;
  362.           if i <= 1 then i := length(newline);
  363.         end;
  364.       end;
  365.    end;
  366.    if pos(^M,newline) <> 0 then delete(newline,pos(^M,newline),1);
  367.  end;
  368.  
  369. function getword(var oldline : str255) : str80;
  370. var wch : char; word : string[80]; i,L : integer;
  371. begin
  372.   word := '';
  373.   i := 0;
  374.   if length(oldline) > 0 then
  375.   begin
  376.     repeat
  377.       i := i + 1;
  378.       wch := oldline[i];
  379.     until (wch = ' ') or (i = length(oldline));
  380.     word := copy(oldline,1,i);
  381.     delete(oldline,1,i);
  382.   end;
  383.   if length(word) >= (lw div 2) - 1 then
  384.   begin
  385.     beep;
  386.     L := length(word) div 2;
  387.     oldline := copy(word,L+1,255) + ' ' + oldline;
  388.     word := copy(word,1,L);
  389.   end;
  390.   getword := rmblks(word);
  391. end;
  392.  
  393.  procedure getlines;
  394.  begin
  395.    nln :=1;
  396.    repeat
  397.      dline[nln]  := rmblks(sline[oln]^);
  398.      nln := nln + 1;
  399.      oln := oln + 1;
  400.    until (length(sline[oln]^) in [0,1]) or (nln = 99);
  401.    lastline := oln-1;
  402.    useddlines := nln-1;
  403.    dline[nln-1] := rmblks(dline[nln-1]) + ^M;
  404.  end;
  405.  
  406. function makestring : str80;
  407. var done : boolean;
  408. begin
  409.    newline := '';
  410.    done := false;
  411.    repeat
  412.      if (length(bufline) < (lw * 2)) and (nln < useddlines) then
  413.      repeat
  414.         nln := nln + 1;
  415.         bufline := bufline + ' '+ dline[nln];
  416.      until (length(bufline) > lw) or (nln = useddlines);
  417.      word := getword(bufline);
  418.      if (length(word) + length(newline)) <= lw then
  419.         newline := newline + ' ' + word
  420.      else
  421.      begin
  422.        done := true;
  423.        bufline := word + ' '+ bufline;
  424.      end;
  425.    until done;
  426.    makestring := rmblks(newline);
  427.    nlcnt := nlcnt + 1;
  428. end;
  429.  
  430. procedure formatlines;
  431. var templine : string[80];
  432. begin
  433.    templine := ' ';
  434.    bufline := bufline + ' '+ dline[nln];
  435.    while (oln <= lastline + 1) and (templine <> '') do
  436.    begin
  437.      templine := makestring;
  438.      if (sline[oln]^ = '') and (templine <> '' ) then
  439.      begin
  440.        insertline('X',oln);
  441.        if templine <> '' then lastline := lastline + 1;
  442.      end;
  443.      sline[oln]^ := templine;
  444.      lowvideo;
  445.      if formright then spread(sline[oln]^) else
  446.      if pos(^M,sline[oln]^) <> 0 then delete(sline[oln]^,pos(^M,sline[oln]^),1);
  447.      write(sline[oln]^);clreol; writeln;
  448.      oln := oln + 1;
  449.   end;
  450.   if (sline[oln]^ <> '') and (sline[oln-1]^ <> '') then insertline('',oln-1);
  451. end;
  452.  
  453. procedure formatnotice;
  454. begin
  455.  astring :='Formating.   [please wait]';
  456.  directwrite(0,24,135,astring);
  457. end;
  458.  
  459. begin
  460.   if sline[curline]^ <> '' then
  461.   begin
  462.     y :=wherey;
  463.     bigw;
  464.     gotoxy(1,24);clreol;
  465.     gotoxy(1,25);clreol;
  466.     Formatnotice;
  467.     littlew;
  468.     gotoxy(1,y);
  469.     initialize;
  470.     if formright then lw := linewidth else lw := linewidth + 5;
  471.     oln := curline;
  472.     getlines;
  473.     oln := curline;
  474.     nln := 1;
  475.     formatlines;
  476.     curline := oln;
  477.     oln := (nln + 1) - nlcnt;
  478.     if nlcnt < nln then deletelines(curline,oln);
  479.     writewrapon;
  480.     wpstatus;
  481.   end
  482.   else curline := curline + 1;
  483. end;
  484.  
  485. PROCEDURE DrawWin(x1,y1,x2,y2 : integer);
  486. var x,y : integer;
  487. begin
  488.   Window(1,1,80,25);
  489.   gotoxy(x1,y1);  Write(chr(213));
  490.   for x := x1+1 to x2-1 do Write(chr(205));  Write(chr(184));
  491.   for y := y1+1 to y2-1 do
  492.   begin
  493.     gotoxy(x1,y); write(chr(179));
  494.     gotoxy(X2,y); write(chr(179));
  495.   end;
  496.   gotoxy(x1,y2); write(chr(212));
  497.   for x := x1+1 to x2-1 do write(chr(205)); write(chr(190));
  498.   Window(x1+1,y1+1,x2-1,y2-1);
  499.   ClrScr;
  500. end;
  501.  
  502. PROCEDURE MakeWin(x1,y1,x2,y2 :integer);
  503. begin
  504.   VideoSignal(Off);
  505.   If CrtMode = 7 then screen := monobuffer
  506.   else screen := colorbuffer;
  507.   VideoSignal(On);
  508.   DrawWin(x1,y1,x2,y2);
  509. end;
  510.  
  511. PROCEDURE RemoveWin;
  512. Begin
  513.   VideoSignal(Off);
  514.   If crtmode = 7 then monobuffer := screen
  515.   else colorbuffer := screen;
  516.   VideoSignal(On);
  517.   window(1,1,80,25);
  518. end;
  519.  
  520. PROCEDURE center(var s: str80);
  521. var xl : integer;
  522. begin
  523.   if length(s) > 0 then
  524.   begin
  525.     while (length(s)>0)and(s[1] = ' ') do delete(s,1,1);
  526.     if length(s) >0 then
  527.     for xl := 1 to ((linewidth - length(s)) div 2) do s:= ' '+s;
  528.   end;
  529.   gotoxy(1,wherey);
  530.   write(s);clreol;
  531. end;
  532.  
  533. PROCEDURE form;
  534. begin
  535.   LOWVIDEO;
  536.   gotoxy(1,23); for xx := 1 to 80 do write(chr(205));
  537.   HIGHVIDEO;
  538. end;
  539.  
  540. function ioerr: boolean;
  541. var err : integer;
  542. begin
  543.   err:= ioresult;
  544.   if err <> 0 then
  545.   begin
  546.     ioerr := true;
  547.     writeln;
  548.     write(chr(7),' I/O Error # ',err,', ');
  549.     case err of
  550.      $01,$FF:write('File missing');
  551.      $F1,240:write('Disk full or invalid Directory');
  552.      $04:write('File not open');
  553.      $99:write('Unexpected end of file');
  554.      $08:write('Disk write error');
  555.      $F2:write('File size overflow');
  556.      $F0:write('Disk write error');
  557.      $91:write('Seek beyond end of file');
  558.      243,$F3:write('To many files open');
  559.      else write(' error type unknown');
  560.     end;
  561.     write('. When ready Press <Return>');
  562.     repeat read(kbd,ch) until ch = ^M;
  563.     gotoxy(1,wherey);clreol;
  564.   end
  565.   else ioerr :=false;
  566. end;
  567.  
  568. FUNCTION PrinterOK : boolean;
  569. var ch : char;
  570. var  reg:     registers;
  571.        i:     integer;
  572. begin
  573.   repeat
  574.     reg.ah := $02;
  575.     reg.dx := $00;
  576.     intr($17,reg);
  577.     i := reg.ah;
  578.     if (i = 144) then
  579.     begin
  580.       printerOk := True;
  581.       ch := #27;
  582.     end
  583.     else
  584.     begin
  585.       printerOK := False;
  586.       gotoxy(1,25);clreol;
  587.       Write(^G,'Printer NOT READY!  When Ready Press <RETURN>,  To Quit Press <ESC>');
  588.       repeat
  589.         read(kbd,ch)
  590.       until ch in[^M,#27];
  591.       gotoxy(1,25);clreol;
  592.     end;
  593.   until ch in [#27];
  594. end;
  595.  
  596. FUNCTION UpcaseStr(s: str80) : Str80;
  597. var px : integer;
  598. begin
  599.   for Px := 1 to Length(s) do
  600.   S[px] := Upcase(S[px]);
  601.   UpcaseStr := S;
  602. end;
  603.  
  604. FUNCTION Lowcase(ch : char) : CHAR;
  605. begin
  606.   if Ch in ['A'..'Z'] then lowcase := chr(ord(ch)+32)
  607.   else lowcase := ch;
  608. end;
  609.  
  610. {$I \turbo\Dirlst.pas}
  611. {$I \turbo\sysutil.pas}
  612.  
  613. PROCEDURE help;
  614. label quit;
  615. var
  616.   Hfile : text[$F00];
  617.   hh,item : char;
  618.   Line : string[80];
  619.   Counter : integer;
  620.  
  621. begin
  622.   OldxPos := wherex;
  623.   OldyPos := wherey;
  624.   counter:= 0;
  625.   item := '0';
  626.   makewin(2,1,78,24);
  627.   clrscr;
  628.   if Exist('GLWP.HLP') then
  629.   begin
  630.     Assign(Hfile,'GLWP.HLP');
  631.     Reset(Hfile);
  632.     if ioresult<> 0 then goto quit;
  633.     while not Eof(Hfile) do
  634.     begin
  635.       gotoxy(1,1);
  636.       LowVideo;
  637.       repeat
  638.           Readln(Hfile,Line);
  639.       until  Eof(Hfile) or (Copy(Line,1,4)='.PA'+item);
  640.       if ioresult <> 0 then goto quit;
  641.       repeat
  642.         Write(' ');
  643.         if pos('.PA',line) = 0 then Writeln(line);
  644.         Readln(Hfile,Line);
  645.         if ioresult <> 0  then goto quit;
  646.       until  Eof(Hfile) or (Copy(Line,1,3)= '.PA');
  647.       GotoXY(12,22); highvideo;
  648.       counter := counter + 1;
  649.       if counter = 1 then write('Select Number or Press <Return> for All')
  650.         else  write('< Press any key to continue or Press <ESC> to quit >');
  651.       LowVideo;
  652.       read(Kbd,hh);
  653.       if hh in['0'..'9'] then item := hh else item :=succ(item);
  654.       clrscr;
  655.       if hh = #27 then goto quit;
  656.     end;
  657.     GotoXY(20,22); HighVideo;
  658.     quit :
  659.     close(Hfile);
  660.     if ioerr then;
  661.   end
  662.   else
  663.   begin
  664.     gotoxy(1,1);
  665.     write('Help File missing. Press <RETURN>');clreol;
  666.     repeat Read(kbd,hh) until hh=^M;
  667.   end;
  668.   removewin;
  669.   highvideo;
  670.   gotoxy(OldxPos,OldyPos);
  671. end;
  672.  
  673.  
  674. PROCEDURE WPIBMCH(var Ch : Char);
  675. var
  676.    scancode : byte;
  677.    extended : boolean;
  678.    regs : registers;
  679. begin
  680.   regs.ah := $07;
  681.   MsDos(regs);
  682.   scancode := regs.al;
  683.   if scancode = 0 then
  684.   begin
  685.     extended := true;
  686.     MsDos(regs);
  687.     scancode:= regs.al;
  688.   end
  689.   else extended := false;
  690.   Ch := chr(scancode);
  691.   if extended then
  692.   begin
  693.     case Ch of
  694.           'Q' : Ch := ^C;  { page down key }
  695.           'I' : Ch := ^R;  { page up key }
  696.           'H' : Ch := ^E;  { up arrow key }
  697.           'P' : Ch := ^X;  { down arrow key }
  698.           'M' : Ch := ^D;  { right arrow key }
  699.           'K' : Ch := ^S;  { left arrow key }
  700.           'S' : Ch := ^G;  { delete key }
  701.           ^O  : Ch := ^O;  { TAB KEY}
  702.       ';','w' : Ch := ^U;  { F1 goto Top line}
  703.       '<','u' : Ch := ^J;  { F2 Jump down to end}
  704.           '=' : Ch := ^^;  { F3 find word}
  705.           '>' : Ch := ^^;  { F4 find word}
  706.           '?' : Ch := ^<;  { F5 upcase letter}
  707.           '@' : Ch := ^\;  { F6 lower case}
  708.           'A' : Ch := #205; { center}
  709.           'B' : Ch := #132;  { Form para}
  710.           '[' : ch := #133;  {reform para}
  711.           'C' : Ch := ^N;  { F9 save file}
  712.           'D' : Ch := ^Z;  { F10 quit enter}
  713.           'R' : Ch := ^V;  { insert key }
  714.           'O' : Ch := ^F;  { end key goto end of line}
  715.           'G' : Ch := ^A;  { home key go to start of line}
  716.           #113: ch := #206;
  717.       else Ch := #00;
  718.     End;
  719.   end;
  720. end;
  721.  
  722. PROCEDURE BOutWPForm;
  723. var XX : integer;
  724. begin
  725.     gotoxy(1,1); clreol;
  726.     gotoxy(1,2);
  727.     frow := 1;
  728.     for xx := LNN -20 TO LNN-1 DO
  729.     begin
  730.       makenewline(xx);
  731.       astring :='                                                                               ';
  732.       astring := sline[xx]^ + astring;
  733.       if not nomem then directwrite(0,frow,att,astring);
  734.       frow := frow +1;
  735.     end;
  736. end;
  737.  
  738. PROCEDURE FOutWPForm;
  739. var xx : integer;
  740. begin
  741.   makenewline(lnn-1);
  742.   gotoxy(1,1);
  743.   if LNN > 20 then write(sline[lnn-1]^);clreol;
  744.   gotoxy(1,2);
  745.   frow := 1;
  746.   for xx := LNN TO LNN + 19 DO
  747.   begin
  748.     makenewline(xx);
  749.     astring :='                                                                               ';
  750.     astring := sline[xx]^ + astring;
  751.     if not nomem then directwrite(0,frow,att,astring);
  752.     frow := frow +1;
  753.   end;
  754. end;
  755.  
  756. PROCEDURE SaveWP(filevar : str80);
  757. var Py,xx,endln : integer;
  758.     tempfilename : text;
  759. begin
  760.   If MAXLN > 1 then
  761.   begin
  762.     form;
  763.     if markblock then
  764.     begin
  765.       gotoxy(1,24);
  766.       write('Save Marked Block from line ',markone,' to ',marktwo ,' to disk Y/N ');clreol;
  767.       repeat
  768.          read(kbd,YN); YN := upcase(YN);
  769.       until YN in ['Y','N'];
  770.       if yn = 'N' then exit else yn := 'N';
  771.     end
  772.     else
  773.     begin
  774.       PromptAt(1,24,'Save Document as:' + FileVar +' Y/N ');
  775.       repeat
  776.         read(kbd,YN); YN := upcase(YN);
  777.       until YN in ['Y','N'];
  778.     end;
  779.     if YN = 'N' then
  780.     begin
  781.       filevar :='';
  782.       PromptAt(1,24,'Enter Document Name: ');
  783.       readln(FileVar);
  784.       if FileVar = '' then
  785.       begin
  786.         write('NOT Saved!'); delay(900); exit;
  787.       end;
  788.       filevar := upcasestr(filevar);
  789.       if pos('.',filevar) = 0 then filevar := filevar + '.TXT';
  790.     end;
  791.     if markblock then
  792.     begin
  793.        xx := markone-1;
  794.        endln := marktwo;
  795.     end
  796.     else
  797.     begin
  798.       xx := 0;
  799.       endln := maxln;
  800.     end;
  801.     PromptAt(1,24,'Saving Document: '+ FileVar);
  802.     assign(wpFileName,FileVar);
  803.     if exist(filevar) then
  804.     begin
  805.       tempfile := filevar;
  806.       py := pos('.',tempfile);
  807.       if py <> 0 then delete(tempfile,py,4);
  808.       tempfile := tempfile + '.bak';
  809.       if exist(tempfile) then
  810.       begin
  811.         assign(tempfilename,tempfile);
  812.         erase(tempfilename);
  813.       end;
  814.       if tempfile <> filevar then
  815.       begin
  816.         rename(wpfilename,tempfile);
  817.         if ioerr then beep;
  818.       end;
  819.     end;
  820.     assign(WPFileName,FileVar);
  821.     if markblock then
  822.     begin
  823.       markblock := false;
  824.       gotoxy(1,22); clreol;
  825.     end
  826.     else wpfilevar :=filevar;
  827.     rewrite(WPFileName);
  828.     if ioerr then
  829.     begin
  830.       close(wpfilename); if ioerr then exit;
  831.     end;
  832.     repeat
  833.       xx := xx + 1;
  834.       writeln(WPFileName,sline[xx]^);
  835.       if ioerr then
  836.       begin
  837.         close(wpfilename); if ioerr then exit; exit;
  838.       end;
  839.     until (xx >= endln);
  840.     if pos(^Z,sline[xx]^) = 0 then writeln(wpfilename,^Z);
  841.     close(WPFileName);
  842.     if ioerr then exit;
  843.   end;
  844. end;
  845.  
  846. PROCEDURE WPInputStr(var S: str80;L,X,Y : Integer;Term :CharSet;var TC : Char);
  847. var
  848.   spn,P,NLN,count,Tcount : Integer;
  849.   LTR,LTRA,Ch,Fch : Char;
  850.  
  851. PROCEDURE movelinesdown(curLn : integer; NumLn : integer);
  852. var termline : string[79];
  853. begin
  854.    for nln := maxln to maxln + numln do makenewline(nln);
  855.    for nln := maxln+Numln downto curln+numln do sline[nln]^ := sline[nln-numln]^;
  856.    maxln := maxln + numln;
  857.    if numln > 1 then
  858.    for nln := curln+1 to curln + numln do sline[nln]^ := '';
  859. end;
  860.  
  861. PROCEDURE movelinesup(curLn : integer; NumLn : integer);
  862. var termline : string[79];
  863. begin
  864.    for nln := maxln to maxln + numln do makenewline(nln);
  865.    for nln := curln-1 to maxln do sline[nln]^ := sline[nln+numln]^;
  866.    for nln := maxln to maxln + numln do sline[nln]^ := '';
  867.    maxln := maxln - numln;
  868.    if lnn > maxln then begin lnn := maxln; if not (ch in[^Y,^H]) then ch := ^R; end;
  869. end;
  870.  
  871. PROCEDURE return;
  872. begin
  873.   NewLine := Copy(S,P + 1,L);
  874.   Delete(S,P+1,L);
  875.   gotoxy(1,Y+1);
  876.   Write(S);clreol;
  877.   gotoxy(1,22); DelLine;
  878.   gotoxy(1,Y+2);
  879.   if y <= 20 then
  880.   begin
  881.      gotoxy(1,Y+2); insline;
  882.      write(newline);
  883.      P:= wherey;
  884.      clreol;
  885.      gotoxy(1,22);clreol;
  886.      gotoxy(1,P);
  887.   end;
  888.   x := 0;
  889.   p := 0;
  890.   movelinesdown(lnn,1);
  891.   sline[lnn+1]^ :=newline;
  892. end;
  893.  
  894. PROCEDURE MakeString;
  895. begin
  896.   if P < L then
  897.   begin
  898.     if ch = ^Q then
  899.     begin
  900.       write(chr(7));
  901.       gotoxy(1,22); write('Insert Control Character');
  902.       GotoXY(X + 1 + P,Y + 1);
  903.       ch:= #00; read(kbd,ch);
  904.       gotoxy(1,22); clreol;
  905.       GotoXY(X + 1 + P,Y + 1);
  906.     end;
  907.     if InsertOn then
  908.     begin
  909.       if Length(S) >= L-1 then
  910.       begin
  911.         if p >= L-1 then begin beep; exit; end;
  912.         p := p+1;
  913.         pp:=p;
  914.         Insert(Ch,S,P);
  915.         return;
  916.         p := pp;
  917.         exit;
  918.       end;
  919.       P := P + 1;
  920.       Insert(Ch,S,P);
  921.       Write(Copy(S,P,L));clreol;
  922.     end
  923.     else
  924.     begin
  925.       if (P = Length(S)+1) or (P=0) and (Length(S)=1)
  926.       then S := S + Ch
  927.       else
  928.       delete(S,P + 1,1);
  929.       P := P + 1;
  930.       Insert(Ch,S,P);
  931.      Write(copy(S,P,L));clreol;
  932.     end;
  933.     if MaxLn < LNN then MaxLn :=LNN;
  934.   end
  935.   else Beep;
  936. end;
  937.  
  938. PROCEDURE backspace;
  939. begin
  940.   fch := ch;
  941.   Last := online + 1;
  942.   if (LNN = maxln) and (p=0) and (length(s)=0) then
  943.   begin                 {if at the end then just move up}
  944.     Ch :=^E;
  945.     Maxln := maxln - 1;
  946.   end
  947.   else        {else change to ^Y and delete current the line}
  948.   if (P = 0) and (Length(s) = 0) then Ch := ^Y
  949.  
  950.   else            { else copy current line upto next line}
  951.   if (Length(s) + Length(sline[LNN-1]^) <= 79) and (P = 0) and (LNN >1) then
  952.   begin
  953.     if S <> '' then Temp := Copy(S,P+1,L);
  954.     s := '';
  955.     ckln := sline[lnn-1]^;
  956.     if (ckln <> '') and (ckln[length(ckln)] <> ' ') then
  957.     sline[lnn-1]^ := sline[lnn-1]^ + ' ' + Temp {move with space}
  958.  
  959.     else
  960.     sline[lnn-1]^ := sline[lnn-1]^ + Temp;   {move without space}
  961.     gotoxy(1,y);
  962.     write(sline[lnn-1]^); clreol; {write new line}
  963.     gotoxy(1,Y+1); delline;
  964.     gotoxy(1,21); insline;
  965.     LineNum := 21 - Last + lnn;
  966.     if linenum > 0 then
  967.     begin
  968.         makenewline(linenum+1);
  969.         write(sline[LineNum+1]^);clreol;
  970.     end;
  971.     P := length(ckln);
  972.     gotoxy(p+1,y);
  973.     temp := sline[lnn-1]^;
  974.     if lnn < maxln then movelinesup(lnn,1);
  975.     sline[lnn-1]^ := temp;
  976.     ch := ^E;
  977.   end;
  978. end;
  979.  
  980. PROCEDURE TabLeft;
  981. begin
  982.   if P > 0 then
  983.   begin
  984.     count := P;
  985.     repeat
  986.       count := count - 1;
  987.       LTR := S[count];
  988.       LTRA := S[count-1];
  989.       P := P - 1;
  990.     until ((LTR = ' ') and (LTRA in [#33..#126])) or (P = 0);
  991.     if P > 0 then P := P-1
  992.   end
  993.   else beep;
  994. end;
  995.  
  996. PROCEDURE TabRight;
  997. begin
  998.   if P < Length(S) then
  999.   begin
  1000.     count := P;
  1001.     repeat
  1002.       count := count + 1;
  1003.       LTR:= S[count];
  1004.       LTRA := S[count+1];
  1005.       P := P + 1;
  1006.     until ((LTR = ' ') and (LTRA in [#33..#126]))or (P = Length(S));
  1007.   end
  1008.   else
  1009.   begin
  1010.     count := P;
  1011.     if lnn > 1 then ckln := sline[lnn-1]^ else ckln := '';
  1012.     if ckln <> '' then
  1013.     repeat
  1014.       count := count + 1;
  1015.       LTR:= ckln[count];
  1016.       LTRA := ckln[count+1];
  1017.       s := s + ' ';
  1018.       p:=p+1;
  1019.     until ((LTR = ' ') and (LTRA in [#33..#126])) or (P = length(ckln));
  1020.   end;
  1021. end;
  1022.  
  1023. PROCEDURE upcaseltr;
  1024. begin
  1025.   s[p+1] := upcase(s[p+1]);
  1026.   Write(Copy(S,P + 1,L));clreol;
  1027.   ch:=^D;
  1028. end;
  1029.  
  1030. PROCEDURE lowcaseltr;
  1031. begin
  1032.   s[p+1] := lowcase(s[p+1]);
  1033.   Write(Copy(S,P + 1,L));clreol;
  1034.   ch:=^D;
  1035. end;
  1036.  
  1037. PROCEDURE DeleteLeftChar;
  1038. begin
  1039.   Delete(S,P,1);
  1040.   Write(^H,copy(S,P,L));clreol;
  1041.   P := P - 1;
  1042. end;
  1043.  
  1044. PROCEDURE DeleteChar;
  1045. begin
  1046.   if P < Length(S) then
  1047.   begin
  1048.     Delete(S,P + 1,1);
  1049.     Write(Copy(S,P + 1,L));clreol;
  1050.   end;
  1051. end;
  1052.  
  1053. PROCEDURE MarkTop;
  1054. begin
  1055.   inserton := true;
  1056.   MarkOne := LNN;
  1057.   GOTOXY(1,22);clreol; lowvideo;
  1058.   WRITE('Top of Block Marked at Line: ',MarkOne);
  1059.   normvideo;
  1060. end;
  1061.  
  1062. PROCEDURE MarkBottom;
  1063. begin
  1064.   MarkTwo := LNN;
  1065.   xx := 0;
  1066.   repeat
  1067.     dline[xx+1] := sline[markone + xx]^;
  1068.     xx := xx +1;
  1069.   until (xx >= (marktwo + 1 - markone)) or (xx = 99);
  1070.   GOTOXY(1,22);clreol;
  1071.   lowvideo;
  1072.   WRITE('Top of Block Marked at Line: ',MarkOne,' - Bottom Mark at Line: ',MarkTwo);
  1073.   normvideo;
  1074.   if MarkOne < MarkTwo then MarkBlock := true else markblock := false;
  1075.   if markone >= marktwo then
  1076.   begin
  1077.     markone := 0;
  1078.     marktwo := 0;
  1079.     markblock := false;
  1080.     GOTOXY(1,22);clreol;
  1081.   end;
  1082. end;
  1083.  
  1084.  PROCEDURE KopyBlock;
  1085.  begin
  1086.    if (MarkBlock) and (sline[lnn]^ = '') then
  1087.    begin
  1088.      if marktwo - markone > 99 then marktwo := markone + 98;
  1089.      gotoxy(1,22); clreol;
  1090.      PriorLN := LNN;
  1091.      movelinesdown(lnn,(marktwo-markone)+1);
  1092.      for nln:= lnn to lnn +(marktwo-markone) do sline[NLN]^ := dline[nln-lnn+1];
  1093.      MarkBlock := false;
  1094.    end else
  1095.    if (lnn >= markone) and (lnn <= marktwo) then
  1096.    begin
  1097.      bigw;
  1098.      beep;
  1099.      PromptAt(1,24,'Delete Lines '); write(markone,' to ',marktwo,' ? Y/N');
  1100.      repeat read(kbd,yn);yn :=upcase(yn); until yn in ['Y','N'];
  1101.      if yn = 'Y' then  movelinesup(markone+1,marktwo-markone+1);
  1102.      markblock := false;
  1103.      markone:= 0;
  1104.      marktwo :=0;
  1105.      gotoxy(1,22); clreol;
  1106.    end;
  1107.    wpstatus;
  1108. end;
  1109.  
  1110. PROCEDURE Load66;
  1111. begin
  1112.   if sline[lnn]^ = '' then
  1113.   begin
  1114.     bigw;
  1115.     Inserton := true;
  1116.     if lnn mod 20 = 0 then priorln := lnn +1 else priorln := lnn;
  1117.     repeat
  1118.        PromptAt(1,24,'Read Disk Directory ? Y/N ');
  1119.        repeat read(kbd,yn); yn := upcase(yn); until yn in['Y','N'];
  1120.        if yn = 'Y' then ListDir;
  1121.        PromptAt(1,24,'Enter Name of Disk Text File to Merge: ');
  1122.        read(DFilevar);
  1123.        if DFilevar <> '' then
  1124.        begin
  1125.          if pos('.',dfilevar) = 0 then dfilevar := dfilevar + '.TXT';
  1126.          assign(DFileName,DFilevar);
  1127.          reset(DFileName);
  1128.          if ioerr then begin wpstatus; exit; end;
  1129.        end;
  1130.      until not ioerr;
  1131.      if DFilevar <> '' then
  1132.      begin
  1133.        while not eof(DFileName) do
  1134.        begin
  1135.          xx := xx + 1;
  1136.          if xx <= 99 then Readln(DFileName,dline[xx])
  1137.          else readln(DFileName,junk);
  1138.          if ioerr then
  1139.          begin
  1140.            close(Dfilename); if ioerr then exit;
  1141.            wpstatus;
  1142.            exit;
  1143.          end;
  1144.       end;
  1145.       close(DFileName);
  1146.       if ioerr then
  1147.       begin
  1148.         close(Dfilename); if ioerr then exit;
  1149.         wpstatus;
  1150.         exit;
  1151.       end;
  1152.       if xx > 99 then xx := 99;
  1153.       NewLine := Copy(S,P + 1,L);
  1154.       Delete(S,P+1,L); gotoxy(1,Y+1);
  1155.       if Y<20 then write(S);clreol;
  1156.       count := 1;
  1157.       makenewline(maxln+1);
  1158.       movelinesdown(lnn,xx);
  1159.       for nln:= lnn to lnn +xx do sline[NLN]^ := dline[nln-lnn+1];
  1160.     end;
  1161.     wpstatus;
  1162.   end else begin beep; ch := #00; end;
  1163. end;
  1164.  
  1165. PROCEDURE YankItOut;
  1166. begin
  1167.   Last := online+1;
  1168.   if S <> '' then Temp := Copy(S,P+1,L);
  1169.   Write('');clreol;
  1170.   Delete(S,P + 1,L);
  1171.   if (P = 0) and (Length(S) = 0) then
  1172.   begin
  1173.     gotoxy(1,Y+1); delline;
  1174.     gotoxy(1,21); insline;
  1175.     if last > 1 then LineNum := lnn +(21 - Last) else linenum := lnn;
  1176.     makenewline(linenum);
  1177.     makenewline(linenum+1);
  1178.     write(sline[LineNum+1]^); clreol;
  1179.     gotoxy(1,last);
  1180.     gotoxy(1,22); clreol;
  1181.     gotoxy(1,Y+1);
  1182.     if lnn >= maxln then makenewline(lnn+1);
  1183.     if lnn < maxln then movelinesup(lnn+1,1);
  1184.     if maxln < LNN then Maxln := LNN;
  1185.     if fch in [^H,#127] then
  1186.     begin
  1187.       P := length(sline[lnn-1]^);
  1188.       ch := ^E;
  1189.       fch:=#00
  1190.     end else P := 0;
  1191.   end;
  1192. end;
  1193.  
  1194. PROCEDURE centerstr;
  1195. begin
  1196.   center(s);
  1197.   P:= 0;
  1198.   gotoxy(1,wherey);
  1199.   if Lnn < maxln then ch := ^X;
  1200. end;
  1201.  
  1202. PROCEDURE searchfile;
  1203. begin
  1204.   bigw;
  1205.   if Fword = '' then
  1206.   begin
  1207.     PromptAt(1,24,'Enter word to search for: ');
  1208.     readln(Fword);
  1209.     if fword <> '' then begin gotoxy(27,24);write(fword,' searching...'); end;
  1210.   end
  1211.   else
  1212.   begin
  1213.     PromptAt(1,24,'Continue Search for: '+Fword+ ' ? Y/N ');
  1214.     repeat
  1215.       read(kbd,Fch);
  1216.       Fch := upcase(fch);
  1217.     until Fch in ['Y','N'];
  1218.     if Fch = 'N' then
  1219.     begin
  1220.       PromptAt(1,24,'Enter word to search for: ');
  1221.       readln(Fword);
  1222.     end else write(Fch,' searching...');
  1223.   end;
  1224.   if Fword <> '' then
  1225.   begin
  1226.     Fword := upcasestr(Fword);
  1227.  
  1228.     Lns := Lnn-1;
  1229.     if Lnn < Maxln then
  1230.     repeat
  1231.        Lns := Lns +1;
  1232.        if length(sline[lns]^) >0 then ckln := copy(sline[lns]^,p+1,79)
  1233.        else ckln := sline[lns]^;
  1234.        ckln := upcasestr(ckln);
  1235.        pp := p;
  1236.        if pos(Fword,ckln) <> 0 then
  1237.        begin
  1238.          if LNS = lnn then
  1239.          begin
  1240.            P := pos(fword,ckln) +length(fword)-1 +pp;
  1241.            ch := #00;
  1242.          end
  1243.          else
  1244.          begin
  1245.            if lns < 20 then Lnn := lns else Lnn := lns -20;
  1246.            p := 0;
  1247.          end;
  1248.        end
  1249.        else
  1250.        p :=0;
  1251.      until (Lns >= maxln) or (pos(Fword,ckln) <> 0);
  1252.      if lns >= maxln then
  1253.      begin
  1254.        bigw;
  1255.        gotoxy(1,24); clreol;
  1256.        write(chr(7),'"',Fword,'" not found! Press any key to continue');
  1257.        read(kbd,zip);
  1258.        Fword := '';
  1259.        if (Maxln > 20) and (ch <> #00) then
  1260.        begin
  1261.          LNN := MaxLN-20;
  1262.          Ch := ^C;
  1263.        end
  1264.        else ch := #00;
  1265.      end;
  1266.    end
  1267.    else ch := #00;
  1268.    wpstatus;
  1269.    GotoXY(X + P + 1,Y + 1);
  1270.  end;
  1271.  
  1272. PROCEDURE moveleft;
  1273. begin
  1274.   if P > 0 then P := P - 1 else Beep;
  1275. end;
  1276.  
  1277. PROCEDURE moveright;
  1278. begin
  1279.   if P < Length(S) then P := P + 1 else beep;
  1280. end;
  1281.  
  1282. PROCEDURE wraponoff;
  1283. begin
  1284.    WrapOn := not WrapOn;
  1285.    writeWrapOn;
  1286.  end;
  1287.  
  1288. PROCEDURE InsertOnOff;
  1289. begin
  1290.   bigw;
  1291.   gotoxy(36,24); clreol;
  1292.   InsertOn := not InsertOn;
  1293.   lowvideo;
  1294.   if InsertOn then write('Insert-On: File-> ',WPFileVar)
  1295.   else write('OverWrite: File-> ',WPFileVar);
  1296.   highvideo;
  1297. end;
  1298.  
  1299. PROCEDURE PutItBack;
  1300. begin
  1301.   if Length(S + Temp) <= 79 then
  1302.   insert(Temp,S,P+1) else
  1303.   begin
  1304.     beep;
  1305.     repeat
  1306.       gotoxy(1,22);
  1307.       write('No room for insertion. Press <ESC> Key and insert blank line');
  1308.       delay(400);
  1309.       if keypressed then Read(KBD,Ch);
  1310.       gotoxy(1,22);clreol;
  1311.       delay(150);
  1312.     until Ch = #27;
  1313.   end;
  1314.   gotoXY(X + 1,Y + 1);
  1315.   Write(S);clreol;
  1316. end;
  1317.  
  1318.  
  1319. begin {wpinstring}
  1320.   GotoXY(X + 1,Y + 1); {Write(S);clreol;}
  1321.   fcol := x; frow := Y;
  1322.   astring :='                                                                               ';
  1323.   astring := s + astring;
  1324.   directwrite(fcol,frow,att,astring);
  1325.   if priorch = ^^ then P := PP else
  1326.   if length(sline[lnn]^) < PP then P := length(sline[lnn]^) else P := PP;
  1327.   tcount := 0;
  1328.   count := 0;
  1329.   xx := 0;
  1330.   REPEAT
  1331.     if markblock then
  1332.     begin
  1333.       GOTOXY(1,22);clreol;
  1334.       lowvideo;
  1335.       WRITE('Top of Block Marked at Line: ',MarkOne,' - Bottom Mark at Line: ',MarkTwo);
  1336.       highvideo;
  1337.     end;
  1338.     littlew;
  1339.     PP := P;
  1340.     GotoXY(X + P + 1,Y + 1);
  1341.     WPIBMCH(Ch);
  1342.     if ch in[^C,^J,^X,^<,^U,^\,' ',^D,^H,#127,^S] then
  1343.     begin
  1344.       if (ch =^C ) and ((maxln <= 20) or (maxln-(21-online)<lnn) and (online<>0)) then ch := #00;
  1345.       if (ch in[^C,^J,^X]) and (lnn >= maxln) then ch :=#00;
  1346.       if (ch = ^J) and ((lnn <= 20) and (maxln  <=20)) then
  1347.       begin
  1348.         online := maxln-1;
  1349.         Lnn := maxln-1;
  1350.         ch  := ^X;
  1351.       end;
  1352.       Case Ch of
  1353.         ^<  : upcaseltr;
  1354.         ^\  : lowcaseltr;
  1355.         ^J  : begin LNN := MaxLN-20; Ch := ^C ; end;
  1356.         ^U  : begin LNN := 1; FOutWPForm; online := 1; end;
  1357.         ' ' : begin
  1358.                 if (Length(S) >= linewidth-5) and (P >= linewidth) and WrapOn
  1359.                 then
  1360.                 begin
  1361.                   if S[p] <> ' ' then
  1362.                   S := S + Ch;
  1363.                   Ch := ^M;
  1364.                 end;
  1365.               end;
  1366.         ^D  : if LNN <= maxln then
  1367.               begin
  1368.                 if (P = Length(S)) and (LNN <maxln) then
  1369.                 begin
  1370.                   P := 0;
  1371.                   Ch := ^X;
  1372.                 end;
  1373.               end else ch := #00;
  1374.     ^H,#127 :  backspace;
  1375.  
  1376.         ^S  : begin
  1377.                 if (P = 0) then if LNN > 1 then
  1378.                 begin
  1379.                    P := length(sline[lnn-1]^);
  1380.                    Ch := ^E;
  1381.                 end else Ch := #00;
  1382.               end;
  1383.  
  1384.        end;
  1385.     end;
  1386.  
  1387.     case Ch of
  1388.  #32..#125,^Q : MakeString;
  1389.       #205    :  Centerstr;
  1390.       ^^      :  Searchfile;
  1391.       ^N      :  begin bigw; savewp(wpfilevar); wpstatus; end;
  1392.       ^O      :  TabLeft;
  1393.       ^I      :  TabRight;
  1394.       ^S      :  Moveleft;
  1395.       ^D      :  Moveright;
  1396.       ^A      :  P := 0;
  1397.       ^F      :  P := Length(S);
  1398.       ^G      :  DeleteChar;
  1399.       ^H,#127 :  if P > 0 then  DeleteleftChar else beep;
  1400.       ^T      :  MarkTop;
  1401.       ^B      :  MarkBottom;
  1402.       ^K      :  KopyBlock;
  1403.       ^L      :  Load66;
  1404.       ^Y      :  YankItOut;
  1405.       ^M      :  Return;
  1406.       ^P      :  PutItBack;
  1407.       ^V      :  InsertOnOff;
  1408.       ^W      :  wraponoff;
  1409.       #132    :  begin formright := true; formpara(lnn); ch := ^K; end;
  1410.       #133    :  begin formright := false; formpara(lnn); ch := ^K; end;
  1411.       #206    :  help;
  1412.      else if not (Ch in Term) then beep;
  1413.     end;
  1414.     PP := P;
  1415.     if not (ch in term) then textinfo;
  1416.     priorch := Ch;
  1417.     priorP := P;
  1418.     if (ch = ^E) and (lnn = 1) then begin beep; ch:=#00 end;
  1419.   until Ch in Term;
  1420.   TC := Ch;
  1421. end;
  1422.  
  1423.  
  1424. PROCEDURE WRITEHIGH(PromptStr : Str80);
  1425. var xx : integer;
  1426. begin
  1427.    for xx := 1 to length(PromptStr) do
  1428.    begin
  1429.      if ((PromptStr[xx] in ['A'..'Z']) and  (PromptStr[xx+1] = '(')
  1430.          or (pos(':',PromptStr) >= xx)) then highvideo else lowvideo;
  1431.      write(PromptStr[xx]);
  1432.   end;
  1433. end;
  1434.  
  1435.  
  1436. PROCEDURE PROMPT(PromptStr : Str80; TC_Set : CharSet; var CH : Char);
  1437. var pc : char;
  1438. begin
  1439.   gotoxy(1,24);
  1440.   writehigh(PromptStr);clreol;
  1441.   repeat
  1442.     read(kbd,pc);
  1443.     CH := upcase(pc);
  1444.     if not(CH in TC_Set) then Beep;
  1445.   until CH in TC_Set;
  1446.   write(CH);
  1447.   highvideo;
  1448. end;
  1449.  
  1450. PROCEDURE ClearTextWindow;
  1451. begin
  1452.   littlew;
  1453.   GotoXY(1,1);
  1454.   clrscr;
  1455.   bigw;
  1456. end;
  1457.  
  1458. PROCEDURE printer;
  1459. var keych : char;  n : integer;
  1460. begin
  1461.   if printerok then
  1462.   begin
  1463.   ClearTextWindow;
  1464.   gotoxy(1,1);
  1465.   writeln('You may send Control or Escape Character sequences to your printer for ');
  1466.   writeln('the purpose of setting your print style. (i.e. correspondence quality) ');
  1467.   writeln('Press ALL the necessary keys, then press return.  See your printer''s');
  1468.   writeln('instruction manual for more information.');
  1469.   repeat
  1470.     read(kbd,keych);
  1471.     write(keych);
  1472.     case keych of
  1473.       #27    : write(lst,#27);
  1474.       ^A..^Z : write(lst,keych);
  1475.       else write(lst,keych);
  1476.     end;
  1477.   until keych = ^M;
  1478.   WRITELN(LST);
  1479.   for n := 1 to 2 do
  1480.   writeln(lst,'abcdefghijklmnopqrstuvwxyz..1234567890/+-!?:ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  1481.   WRITE(LST,CHR(12));
  1482.   ClearTextWindow
  1483.   end;
  1484. end;
  1485.  
  1486. PROCEDURE setprint;
  1487. var Pnumstr,PageStr,PauseStr : string[3];
  1488.     item : char;
  1489. begin
  1490.   noprint := false;
  1491.   ClearTextWindow;
  1492.   repeat
  1493.     PromptAt(1,24,' ');
  1494.     gotoxy(1,1);
  1495.     if pause = 'N' then  PauseStr := 'No' Else PauseStr := 'Yes';
  1496.     if pageYN = 'N' then  PageStr := 'No' Else PageStr := 'Yes';
  1497.     if numYN = 'N' then  PnumStr := 'No' Else PnumStr := 'Yes';
  1498.     writeln('            Print Format Parameters');
  1499.     writeln;
  1500.     writeln('1 - Top Margin is.............: ',Header:3,' lines');clreol;
  1501.     writeln;
  1502.     writeln('2 - Bottom Margin is..........: ',Bottom:3,' lines');clreol;
  1503.     writeln;
  1504.     writeln('3 - Left Margin is............: ',Margin:3,' spaces');clreol;
  1505.     writeln;
  1506.     linewidth := 80 - margin - margin-1;
  1507.     writeln('4 - Maximum Lines per Page is.: ',Pagesize:3,' lines');clreol;
  1508.     writeln;
  1509.     writeln('5 - Pause Between Pages.......: ',PauseStr:3);clreol;
  1510.     writeln;
  1511.     writeln('6 - Automatic Pagination......: ',PageStr:3);clreol;
  1512.     writeln;
  1513.     writeln('7 - Number All Pages..........: ',PnumStr:3);clreol;
  1514.     writeln;
  1515.     writeln('8 - Send setup characters to printer');
  1516.     writeln;
  1517.     writeln('9 - Return to Select Choice Menu');
  1518.     writeln;
  1519.     write('Select Item # to change or press ''C'' to Continue ');
  1520.     repeat
  1521.       read(kbd,item);
  1522.       item := upcase(item);
  1523.     until item in ['1'..'9','C'];
  1524.     if item <> 'C' then
  1525.     begin
  1526.       case item of
  1527.       '1':begin
  1528.             repeat gotoxy(34,3);clreol; readln(header);
  1529.             until header in [1..66];
  1530.           end;
  1531.       '2':begin
  1532.             repeat gotoxy(34,5);clreol; readln(bottom);
  1533.             until bottom in [0..15];
  1534.           end;
  1535.       '3':begin
  1536.             repeat gotoxy(34,7);clreol; readln(margin);
  1537.             until margin in [0..15];
  1538.           end;
  1539.       '4':begin
  1540.             repeat gotoxy(34,9);clreol; readln(pagesize);
  1541.             until pagesize in [40..90];
  1542.           end;
  1543.       '5':begin
  1544.             repeat gotoxy(33,11);clreol; read(kbd,pause);
  1545.             pause := upcase(pause);
  1546.             until pause in ['Y','N'];
  1547.           end;
  1548.       '6':begin
  1549.             repeat gotoxy(33,13);clreol; read(kbd,PageYN);
  1550.             pageYN := upcase(pageYN);
  1551.             until pageYN in ['Y','N'];
  1552.           end;
  1553.       '7':begin
  1554.             repeat gotoxy(33,15); clreol; read(kbd,NumYN);
  1555.             NumYn := Upcase(NumYn);
  1556.             until NumYN in ['Y','N'];
  1557.           end;
  1558.       '8': printer;
  1559.       '9': begin NoPrint := true; item :='C' end;
  1560.        end;
  1561.  
  1562.     end;
  1563.   until item = 'C';
  1564. end;
  1565.  
  1566. PROCEDURE InputWP;
  1567. const
  1568.   Term : CharSet  =  [^X,^M,^E,^K,^L,^R,^C,^Z,^^,^U];
  1569. var
  1570.   TC : Char;
  1571.   top : boolean;
  1572. begin
  1573.   top := true;
  1574.   SAVED := FALSE;
  1575.   LNN := 1;
  1576.   TC := #00;
  1577.   online := 1;
  1578.   FOutWPForm;
  1579.  
  1580.   repeat
  1581.  
  1582.     if ((TC in [^X,^M]) and (online >= 21)) then
  1583.                         begin
  1584.                            online := 20;
  1585.                            littlew;
  1586.                            gotoxy(1,1);delline;
  1587.                            gotoxy(1,21); insline;
  1588.                          end
  1589.   else
  1590.   if (TC = ^E) and (online = 0) then
  1591.                           begin
  1592.                               littlew;
  1593.                               gotoxy(1,21);clreol;
  1594.                               gotoxy(1,1);insline;
  1595.                               if lnn > 1 then write(sline[lnn-1]^);
  1596.                               online := 1;
  1597.                               if (online = 1) and (lnn = 1) then top := true
  1598.                               else top :=false;
  1599.                           end;
  1600.  
  1601.  makenewline(lnn);
  1602.  textinfo;
  1603.  WPInputStr(sline[LNN]^,79,0,online,Term,TC);
  1604.     if LNN <= 0 then LNN := 1;
  1605.     if TC in[^X,^M] then
  1606.     begin
  1607.       LNN := LNN + 1;
  1608.       online := online + 1;
  1609.     end
  1610.  
  1611.     else
  1612.  
  1613.     if (TC = ^E) and (not top or (lnn>1) )then
  1614.     begin
  1615.       if LNN > 1 then LNN := LNN - 1;
  1616.       if online <=0 then online := 1;
  1617.       if online > 20 then online := 20;
  1618.       if (online in[1..20]) then online := online - 1;
  1619.     end;
  1620.  
  1621.   if (TC =^C) and (LNN < aTOPEND +1) then
  1622.   begin
  1623.     TopLine := (trunc(Lnn/20) *20) + 21;
  1624.     Lnn := topline;
  1625.     online := (lnn mod 20);
  1626.     FOutWPForm;
  1627.   end;
  1628.  
  1629.   if (TC in[^K,^L]) and (LNN < aTOPEND +1) then
  1630.   begin
  1631.     online := 1;
  1632.     FOutWPForm;
  1633.   end;
  1634.  
  1635.   if (TC = ^R) then if (LNN <= 20) then
  1636.     begin
  1637.       LNN := 1; FOutWPForm; online := 1;
  1638.     end
  1639.     else
  1640.     if (LNN > 20) then
  1641.     begin
  1642.         BOutWPForm;
  1643.         lnn := lnn -20;
  1644.         online :=1;
  1645.      end;
  1646.  if TC = ^^ then
  1647.    begin
  1648.      LNN := Lns;
  1649.      if LNN > maxln then Lnn := maxln;
  1650.      foutwpform;
  1651.      online := 1;
  1652.      if (TC = ^^) and (pos(fword,ckln) <> 0) then
  1653.         PP := (pos(fword,ckln)-1+ length(fword));
  1654.    end;
  1655.  
  1656.   If MAXLN >= aENDLINE THEN MAXLN := aENDLINE-2;
  1657.  
  1658.   if (TC = ^M) or (TC = ^X) then if LNN = aENDLINE-1 then beep;
  1659.  
  1660.   if LNN <= 0 then LNN := 1
  1661.   else
  1662.   if LNN >= aENDLINE-1 then LNN := aENDLINE-2;
  1663. until TC = ^Z;
  1664. ClearTextWindow
  1665. end;
  1666.  
  1667. PROCEDURE EnterWP;
  1668. begin
  1669.     InsertOn := true;
  1670.     wpstatus;
  1671.     writewrapon;
  1672.     InputWP;
  1673.     gotoxy(1,25);clreol;
  1674. end;
  1675.  
  1676. PROCEDURE GETWPFILE;
  1677. var
  1678.   xx : integer;
  1679.   NewFileVar : string[60];
  1680. begin
  1681.   WPFileVar := 'NONAME.TXT';
  1682.   xx := 0;
  1683.   markblock :=false;
  1684.   MAXLN := 0;
  1685.   for xx := 1 to aendline do if sline[xx] <> nil then sline[xx]^ := '';
  1686.   for xx := 1 to 99 do  dline[xx] := '';
  1687.   cursor(on);
  1688.   repeat
  1689.     astring := cnotice;
  1690.     directwrite(0,0,7,astring);
  1691.     PROMPT('Select Choice:  C(reate or R(evise document,  D(irectory,  Q(uit,  U(tilitys ', ['D','C','R','Q','U'], Ch);
  1692.     if ch = 'U' then
  1693.     begin
  1694.       sysutil;
  1695.       form;
  1696.     end;
  1697.     if Ch = 'D' then
  1698.     begin
  1699.       ClearTextWindow;
  1700.       ListDir;
  1701.       window(1,1,80,25);
  1702.       form;
  1703.     end;
  1704.   if Ch = 'C' then
  1705.   begin
  1706.     PromptAt(1,24,'Enter Name of Document To Create: ');
  1707.     readln(WPFileVar);
  1708.     if WPFileVar = '' then WPFileVar := 'NONAME.TXT';
  1709.     IF pos('.',wpfilevar) = 0 then wpfilevar := wpfilevar + '.TXT';
  1710.     wpfilevar := UPCASESTR(WPFILEVAR);
  1711.     gotoxy(1,24); clreol;
  1712.   end;
  1713.  
  1714.   if Ch =  'R' then
  1715.   begin
  1716.     PromptAt(1,24,'Enter Name of Document To Load: ');
  1717.     readln(WPFileVar);
  1718.     if wpfilevar <> ''then
  1719.     begin
  1720.       IF pos('.',wpfilevar) = 0 then wpfilevar := wpfilevar + '.TXT';
  1721.       wpfilevar := UPCASESTR(WPFILEVAR);
  1722.       if WPFileVar = '' then ch := #00;
  1723.       gotoxy(1,24); clreol; write('Loading: ',WPFileVar);
  1724.       assign(WPFileName,WPFileVar);
  1725.       Reset(WPFileName);
  1726.       if ioresult <> 0 then
  1727.       begin
  1728.         PROMPT('File not found - Create New File ?  Y/N  ',['Y','N'],Ch);
  1729.         if Ch = 'Y' then ch := 'C';
  1730.         if Ch = 'N'then ch := #00;
  1731.       end
  1732.       else
  1733.       begin
  1734.         xx := 0;
  1735.         while not eof(WPFileName) do
  1736.         begin
  1737.           xx := xx + 1;
  1738.           makenewline(xx);
  1739.           if xx <= aendline-2 then Readln(WPFileName,sline[xx]^)
  1740.           else readln(wpfilename,junk);
  1741.           if ioerr then
  1742.           begin
  1743.              Close(wpfilename); exit;
  1744.           end;
  1745.           MAXLN := xx;
  1746.           if MAXLN > aendline then MAXLN := aendline-2;
  1747.         end;
  1748.         makenewline(xx+1);
  1749.         close(WPfileName);
  1750.         if ioerr then exit;
  1751.       end;
  1752.     end
  1753.     else ch := #00;
  1754.   end;
  1755.   until ch in ['C','R','Q'];
  1756.   if Ch <> 'Q' then Ch := 'W';
  1757. end;
  1758.  
  1759.  
  1760. PROCEDURE PrintIt(mm : boolean);
  1761. label quit;
  1762. VAR P1,P2,cnum,pagenum,counter,nl,LCNT,LM,Posn,lx : INTEGER;
  1763.     RP : char;
  1764.     tline : string[79];
  1765.     spaces : string[25];
  1766.     Firstname : string[40];
  1767.     SurName : string[40];
  1768.     LASTNAME,PAUSED : BOOLEAN;
  1769.     bufln,cmdline : string[79];
  1770. begin
  1771.   if printerok then
  1772.   begin
  1773.     noprint := false;
  1774.     PAUSED := FALSE;
  1775.     LASTNAME := FALSE;
  1776.     xx := 0;
  1777.     pageNum := 1;
  1778.     firstName := '';
  1779.     SURname := '';
  1780.     tline:= '';
  1781.     for xx := 1 to 99 do dline[xx] := '';
  1782.     xx:=0;
  1783.     COUNTER := 0;
  1784.     If maxln < 1 then getWPfile;
  1785.     spaces :=  ' ';
  1786.     PromptAt(1,24,'Review Print Format Parameters ? Y/N ');
  1787.     repeat
  1788.       read(kbd,RP);
  1789.       RP := Upcase(RP);
  1790.     until RP in ['Y','N'];
  1791.     if RP = 'Y' then SetPrint;
  1792.     if not noprint then
  1793.     begin
  1794.       ClearTextWindow;
  1795.       if margin > 1 then for LM := 1 to margin do
  1796.       begin
  1797.         spaces := spaces + ' ';
  1798.       end;
  1799.       if MM then
  1800.       begin
  1801.         repeat
  1802.           PromptAt(1,24,'Name of Disk Text File to Merge: ');clreol;
  1803.           read(DFilevar);
  1804.           ClearTextWindow;
  1805.           if DFilevar <> '' then
  1806.           begin
  1807.             IF pos('.',Dfilevar) = 0 then Dfilevar := Dfilevar + '.TXT';
  1808.             assign(DFileName,DFilevar);
  1809.             reset(DFileName);
  1810.             if ioerr then exit;
  1811.           end;
  1812.         until not ioerr;
  1813.       end else DFilevar := ' ';
  1814.       if DFilevar <> '' then
  1815.       begin
  1816.         gotoxy(1,24);clreol;
  1817.         write('Printing: ',WPFilevar);
  1818.         gotoxy(1,1);
  1819.         write('Press  <ESC>  to abort printing');
  1820.         repeat
  1821.           if keypressed then begin read(kbd,ch); if ch = #27 then goto quit; end;
  1822.           if (numYn = 'Y') and (pagenum <> 1) then writeln(lst,spaces,pagenum:39-margin);
  1823.           if ioerr then exit;
  1824.           pagenum := pageNum + 1;
  1825.           if header > 6 then FOR LCNT := 0 TO HEADER-6 DO
  1826.           begin
  1827.             WRITELN(LST);
  1828.             if ioerr then exit;
  1829.           end;
  1830.  
  1831.           if MM then
  1832.           begin
  1833.           repeat
  1834.             if keypressed then begin read(kbd,ch); if ch = #27 then goto quit; end;
  1835.             xx := xx + 1;
  1836.             if xx <= 99 then Readln(DFileName,dline[xx])
  1837.             else readln(DFileName,junk);
  1838.             if ioerr then exit;
  1839.             if xx = 1 then
  1840.             begin
  1841.               FirstName := copy(dline[xx],1,pos(' ',dline[xx])-1);
  1842.               lx := length(dline[xx]);
  1843.               tline := dline[xx];
  1844.               if lx > 0 then
  1845.               repeat
  1846.                 ch := tline[lx];
  1847.                 lx := lx - 1;
  1848.               until ch = ' ';
  1849.               surname :=  copy(dline[xx],lx+2,40);
  1850.             end;
  1851.             ckln := upcasestr(Dline[XX]);
  1852.             IF POS('@@',CKLN) <> 0 THEN LASTNAME := TRUE;
  1853.           until pos('@',dline[xx]) <> 0
  1854.           end
  1855.           else lastname := true;
  1856.  
  1857.           LNN := 1;
  1858.           counter := COUNTER + XX;
  1859.           REPEAT
  1860.             cnum := 0;
  1861.             if keypressed then begin read(kbd,ch); if ch = #27 then goto quit; end;
  1862.             counter := counter +1;
  1863.             ckln := upcasestr(sline[LNN]^);
  1864.             if MM then
  1865.             begin
  1866.               if Pos('{@}',ckln) <> 0 then
  1867.               begin
  1868.                 LNN := Lnn + 1;
  1869.                 for NL := 1 to XX-1 do writeln(lst,spaces,dline[NL]);
  1870.                 if ioerr then exit;
  1871.               end
  1872.               else if Pos('{^',ckln) <> 0 then
  1873.               begin
  1874.                 bufln := sline[lnn]^;
  1875.                 if Pos('{^}',ckln) <> 0 then
  1876.                 begin
  1877.                   Posn := pos('{',sline[LNN]^);
  1878.                   delete(sline[lnn]^,posn,3);
  1879.                   insert(firstname,sline[LNN]^,posn);
  1880.                 end;
  1881.                 ckln := upcasestr(sline[LNN]^);
  1882.                 if Pos('{^^}',ckln) <> 0 then
  1883.                 begin
  1884.                   Posn := pos('{',sline[LNN]^);
  1885.                   delete(sline[lnn]^,posn,4);
  1886.                   insert(surname,sline[LNN]^,posn);
  1887.                 end;
  1888.                 writeln(LST,spaces,sline[LNN]^);
  1889.                 sline[lnn]^ := bufln;
  1890.                 lnn := lnn + 1;
  1891.               end;
  1892.             end;
  1893.             ckln := upcasestr(sline[LNN]^);
  1894.             cmdline := sline[LNN]^;
  1895.             cmdline := cmdline + ' ';
  1896.             if (POS('{NP}',ckln) <> 0) or (pos('{UL}',ckln) <> 0) or (pos('{BP}',ckln) <> 0) then
  1897.             begin
  1898.               write(lst,spaces);
  1899.               if ioerr then exit;
  1900.               if pos('{UL}',ckln) <> 0 then
  1901.               begin
  1902.                 P1 := pos('{',ckln);
  1903.                 delete(cmdline,P1,4);
  1904.                 P2 := pos('{',cmdline);
  1905.                 if p2 = 0 then p2 := length(cmdline);
  1906.                 delete(cmdline,P2,4);
  1907.                 repeat
  1908.                   cnum := cnum + 1;
  1909.                   write(lst,cmdline[cnum]);
  1910.                   if ioerr then exit;
  1911.                 until cnum= P2;
  1912.                 repeat
  1913.                   cnum := cnum - 1;
  1914.                   write(lst,^H);
  1915.                   if ioerr then exit;
  1916.                 until cnum = P1-1;
  1917.                 repeat
  1918.                   cnum := cnum + 1;
  1919.                   write(lst,'_');
  1920.                 if ioerr then exit;
  1921.                 until cnum = P2-1;
  1922.                 if cnum < length(cmdline) then
  1923.                 repeat
  1924.                   cnum := cnum + 1;
  1925.                   write(lst,cmdline[cnum]);
  1926.                   if ioerr then exit;
  1927.                 until cnum >= length(cmdline);
  1928.               end;
  1929.               if pos('{BP}',ckln) <> 0 then
  1930.               begin
  1931.                 P1 := pos('{',ckln);
  1932.                 delete(cmdline,P1,4);
  1933.                 P2 := pos('{',cmdline);
  1934.                 if p2 = 0 then p2 := length(cmdline);
  1935.                 delete(cmdline,P2,4);
  1936.                 repeat
  1937.                   cnum := cnum + 1;
  1938.                   write(lst,cmdline[cnum]);
  1939.                   if ioerr then exit;
  1940.                 until cnum= P2;
  1941.                 repeat
  1942.                   cnum := cnum - 1;
  1943.                   write(lst,^H);
  1944.                   if ioerr then exit;
  1945.                 until cnum = P1-1;
  1946.                 repeat
  1947.                   cnum := cnum + 1;
  1948.                   write(lst,cmdline[cnum]);
  1949.                   if ioerr then exit;
  1950.                until cnum = P2-1;
  1951.                if cnum < length(cmdline) then
  1952.                repeat
  1953.                  cnum := cnum + 1;
  1954.                  write(lst,cmdline[cnum]);
  1955.                  if ioerr then exit;
  1956.                until cnum >= length(cmdline);
  1957.              end;
  1958.              writeln(lst);
  1959.              if ioerr then exit;
  1960.            end
  1961.            else
  1962.            writeln(LST,spaces,sline[LNN]^);
  1963.            if ioerr then exit;
  1964.            ckln := upcasestr(sline[LNN]^);
  1965.            IF (((counter + HEADER + BOTTOM) MOD pagesize = 0) and (pageYN = 'Y'))
  1966.            or (POS('{NP}',ckln) <> 0) THEN
  1967.            BEGIN
  1968.              counter := 0;
  1969.              WRITE(LST,CHR(12));
  1970.              if ioerr then exit;
  1971.              if pause = 'Y' then
  1972.              begin
  1973.                PAUSED := TRUE;
  1974.                gotoxy(2,3);
  1975.                writeln('   Pausing between Pages...');
  1976.                write('Press Any Key to Continue Print');
  1977.                read(kbd,ch);
  1978.                if ch = #27 then goto quit;
  1979.                gotoxy(1,4);clreol;
  1980.              end;
  1981.              if numYn = 'Y' then writeln(lst,spaces,pagenum:39-margin);
  1982.              if ioerr then exit;
  1983.              pagenum := pageNum + 1;
  1984.              if header > 6 then FOR LCNT := 0 TO HEADER-6 DO WRITELN(LST);
  1985.              if ioerr then exit;
  1986.            END;
  1987.            LNN := LNN + 1;
  1988.          until EOF(WPFileName) or (LNN >= MAXLN + 1);
  1989.          xx := 0;
  1990.          write(lst,chr(12));
  1991.          if ioerr then exit;
  1992.          counter := 0;
  1993.          if (pause = 'Y') AND NOT PAUSED then
  1994.          begin
  1995.            PAUSED := FALSE;
  1996.            gotoxy(2,3);
  1997.            writeln('Pausing between Pages');
  1998.            write('Press Return to Continue or Esc to Quit');
  1999.            repeat
  2000.               read(kbd,ch);
  2001.            until ch in [#27,^M];
  2002.            if ch = #27 then goto quit;
  2003.            gotoxy(1,4);clreol;
  2004.          end;
  2005.          if keypressed then
  2006.          begin
  2007.             read(kbd,ch);
  2008.             if ch = #27 then goto quit;
  2009.          end;
  2010.        until lastname or EOF(DfileName);
  2011.        quit:
  2012.        if ch = #27 then WRITE(LST,CHR(12));
  2013.        if ioerr then exit;
  2014.        close(dfilename);
  2015.       end;
  2016.     end;
  2017.   end;
  2018.   clearTextWindow;
  2019.   form;
  2020. end;
  2021.  
  2022. PROCEDURE MailMergePrint;
  2023. begin
  2024.  printit(true);
  2025. end;
  2026.  
  2027. PROCEDURE RegularPrint;
  2028. begin
  2029.   printit(false);
  2030. end;
  2031.  
  2032. PROCEDURE initialize;
  2033. begin
  2034.   clrscr;
  2035.   Typeadapter;
  2036.   nomem := false;
  2037.   if crtmode = 3 then att := 14 else att := 15;
  2038.   form;
  2039.   noprint := false;
  2040.   getdir(0,Cdir);
  2041.   Fword := '';
  2042.   markone:=0;
  2043.   marktwo := 0;
  2044.   WrapOn := true;
  2045.   markblock := false;
  2046.   header := 7;
  2047.   pause := 'N';
  2048.   pageYN := 'Y';
  2049.   numYn := 'N';
  2050.   bottom := 7;
  2051.   pagesize := 66;
  2052.   margin := 9;
  2053.   linewidth := 80 - margin - margin;
  2054.   Temp := '';
  2055.   MAXLN := 0;
  2056.   mark(heaptop);
  2057.   for xx := 1 to endline do sline[xx] := nil;
  2058.   aendline := xx;
  2059.   atopend := xx-20;
  2060. end;
  2061.  
  2062. begin
  2063.   Initialize;
  2064.   GetWPFile;
  2065.   if Ch <> 'Q' then
  2066.   begin
  2067.     repeat
  2068.       priorch := #00;
  2069.       priorP := 0;
  2070.       PP := 0;
  2071.       markblock:=false;
  2072.       PROMPT('Select: E(nter text, G(et file, H(elp, M(erge, P(rint, S(ave, Q(uit, U(tility',
  2073.       ['M','G','S','P','H','E','Q','U'],ch);
  2074.       case Ch of
  2075.         'U' : SysUtil;
  2076.         'E' : EnterWP;
  2077.         'G' : begin
  2078.                 IF (NOT SAVED) and (Maxln >0) THEN
  2079.                 begin
  2080.                   form;
  2081.                   PromptAt(1,24,'File Not Saved!  Save it ? Y/N ');
  2082.                   repeat
  2083.                     read(kbd,Ch);
  2084.                     Ch := upcase(ch);
  2085.                   until Ch in ['Y','N'];
  2086.                   if ch = 'Y' then SaveWP(wpfilevar);
  2087.                 end;
  2088.                 GetWPFile;
  2089.               end;
  2090.         'H' : Help;
  2091.         'M' : Mailmergeprint;
  2092.         'P' : Regularprint;
  2093.         'S' : begin SaveWP(wpfilevar); Saved := True; end;
  2094.       end;
  2095.       form;
  2096.     until UpCase(Ch) = 'Q';
  2097.     if (NOT SAVED) and (MaxLn > 0) then
  2098.     begin
  2099.       beep;
  2100.       PromptAt(1,24,'File Not Saved!  Save it ? Y/N ');
  2101.       repeat
  2102.         read(kbd,Ch);
  2103.         Ch := upcase(ch);
  2104.       until Ch in ['Y','N'];
  2105.       if ch = 'Y' then SaveWP(wpfilevar);
  2106.     end;
  2107.   end;
  2108.   release(heaptop);
  2109.   clrscr;
  2110.  
  2111.   {    Please do not remove the following information from this program                       }
  2112.  
  2113.   writeln('If you find this program useful then please become a registered user by');
  2114.   writeln('sending a support fee of $25.00, or what ever you may be able to afford,');
  2115.   writeln('to:');
  2116.   writeln('      K.S. Software');
  2117.   writeln('      P.O. Box 37093 ');
  2118.   writeln('      Omaha, NE 68137');
  2119.   writeln;
  2120.   writeln('In return for your support fee of $25.00 you will receive the latest ');
  2121.   writeln('program version including turbo pascal source code.');
  2122.   writeln;
  2123.   writeln('In addition you will also receive a copy of "SUMDOS" a memory resident');
  2124.   writeln('utility program that includes:');
  2125.   writeln;
  2126.   writeln('Calculator, Note Pad, Disk Utilities, Read File, Terminal Communications,');
  2127.   writeln('Phone List and Dialer, ASCII Table, Screen Saver, Calendar and a handy');
  2128.   writeln('utility to write screens to disk.');
  2129.   writeln;
  2130.   writeln;
  2131.   writeln('Permission is granted to make copies of this program and distribute copies');
  2132.   writeln('to others for non-profit purposes only.');
  2133.  end.
  2134.  
  2135.